calculate the resistance